<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script>
        $(function (){
                show(1);
            }

        );
        function show(pageNum){
            $.ajax({
                url:"emp/listAjax",
                type:"get",
                data:{"pageNum":pageNum,"pageSize":document.getElementById("pageSize").value},
                dataType:"json",
                success:function (data){
                    if(data.result){
                        alert("成功");
                        var h = "";
                        for(var i in data.empList){
                            var d=data.empList[i];
                            h+="<tr>"
                                +"<th><input name='empnoes' type='checkbox' value='"+d.empno+"'></th>"
                                +"<th>"+i+1+"</th>"
                                +"<th>"+d.ename+"</th>"
                                +"<th>"+d.job+"</th>"
                                +"<th>"+d.mgr+"</th>"
                                +"<th>"+d.hiredate+"</th>"
                                +"<th>"+d.sal+"</th>"
                                +"<th>"+d.comm+"</th>"
                                +"<th>"+d.deptno+"</th>"
                                +"<th><button type='button'  onclick='del("+d.empno+")'class='btn btn-danger'  >删除</button></th>"
                                +"<th><button type='button' onclick='findById("+d.empno+")' class='btn btn-info' >编辑</button></th>"
                                +"</tr>"
                        }
                        $("tbody").html(h)

                        var byPage="<tr>";
                        byPage+="<th colspan='6'>";
                        byPage+="<a onclick='show(1)'>首页</a>";
                        // byPage+="<a onclick='show("+data.pageInfo.pageNum==1?1:data.pageInfo.pageNum-1+")'>上一页</a>";
                        // byPage+="<a onclick='show("+data.pageInfo.pageNum==data.pageInfo.countPage?data.pageInfo.countPage:data.pageInfo.pageNum+1+")'>"+下一页+"</a>";
                        byPage += "<a onclick='show("+(data.pageInfo.pageNum==1?1:data.pageInfo.pageNum-1)+")'>上一页</a>";
                        byPage += "<a onclick='show("+(data.pageInfo.pageNum==data.pageInfo.countPage?data.pageInfo.countPage:data.pageInfo.pageNum+1)+")'>下一页</a>";
                        byPage+="<a onclick='show("+data.pageInfo.countPage+")'>末页</a>";
                        byPage+="</th>";
                        byPage+="</tr>";
                        byPage+=" <select name='pageSize' onChange='show(1)' id='pageSize'>"
                            +"<option value='5'>每页5行</option>"
                            +"<option value='10'>每页10行</option>"
                            +" <option value='20'>每页20行</option>"
                            +" <option value='-1'>显示全部</option>"
                            +" </select>"
                        $("tfoot").html(byPage)

                    }else {
                        alert("失败");
                    }
                }
            });
        }

        function selectAll(obj) {
            var deptnoesVal = document.getElementsByName("deptnoes");
            for(var i = 0;i<deptnoesVal.length;i++){
                deptnoesVal[i].checked=obj.checked;
            }

        }


    </script>
</head>
<body>
<form action="emp/deleteSelect" method="post">
    <table class="table table-condensed">
        <caption><h3>部门管理</h3></caption>
        <thead>
        <tr>
            <th><input type="checkbox" onclick="selectAll(this)"/></th>
            <th>序号</th>
            <th>员工名称</th>
            <th>职位</th>
            <th>mgr</th>
            <th>入职日期</th>
            <th>sal</th>
            <th>comm</th>
            <th>所属部门</th>
            <th>编辑</th>
            <th>删除</th>
        </tr>
        </thead>
        <tbody id="tbody">

        </tbody>
        <tfoot id="tfoot">
        <select name="pageSize" onchange="show(1)" id="pageSize">
            <option value="5">每页5行</option>
            <option value="10">每页10行</option>
            <option value="20">每页20行</option>
            <option value="-1">显示全部</option>
        </select>
        </tfoot>
    </table>
    <button>删除</button>
</form>
</body>
</html>